<?php 
include("safeout.php");
function diskTransform($num = 0)
{
    if ($num / 1024 < 1) {
        return $num . 'KB';
    }
    $num = $num / 1024;
    if ($num / 1024 < 1) {
        return round($num, 3) . 'MB';
    }
    $num = $num / 1024;
    if ($num / 1024 < 1) {
        return round($num, 3) . 'GB';
    }

    $num = $num / 1024;
    if ($num / 1024 < 1) {
        return round($num, 3) . 'TB';
    }

    $num = $num / 1024;
    return round($num, 3) . 'PB';

}
$mquery="select * from ph_admin where admin='".$_SESSION["managername"]."'";
$mresult=mysqli_query($conn,$mquery);
$rowuser = mysqli_fetch_array($mresult);
$ucalist2="select * from ph_admin where admin='".$rowuser["parent"]."'";
$ucaresult2=mysqli_query($conn,$ucalist2);
$rowuser2 = mysqli_fetch_array($ucaresult2);
if($rowuser["thetype"]=="超级管理员"||$rowuser["thetype"]=="管理员"||$rowuser2["thetype"]=="超级管理员"){
$maxhostsize=$rowuser["maxhostsize"];
$currenthostsize=$rowuser["currenthostsize"];
}else{
$maxhostsize=$rowuser2["maxhostsize"];
$currenthostsize=$rowuser2["currenthostsize"];
}

if($_SESSION["thetype"]=="超级管理员"){$result=mysqli_query($conn,"select count(*) from ph_products order by ID desc");}
if($_SESSION["thetype"]=="管理员"){
$query="select admin from ph_admin where admin='".$_SESSION["managername"]."' or parent='".$_SESSION["managername"]."'";
$resulty=mysqli_query($conn,$query);
$array=array();
while($rowy = mysqli_fetch_array($resulty)){
array_push($array,"'".$rowy[admin]."'");
}
$alluser=implode(',', $array);
$result=mysqli_query($conn,"select count(*) from ph_products where user_name in(".$alluser.") order by ID desc");
}
if($_SESSION["thetype"]=="员工"){
$result=mysqli_query($conn,"select * from ph_products where user_name='".$_SESSION["managername"]."' order by ID desc");
}
$rowcount = mysqli_fetch_array($result);

?> 
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<title><?php echo $site_name;?>后台管理-数据汇总</title>
<link href="/bootstrap/css/bootstrap.min.css" title="" rel="stylesheet" />
<link href="/css/mcommon.css" rel="stylesheet" title="" type="text/css" />
<link href="/css/style.css" rel="stylesheet" type="text/css"  />
<link rel="shortcut icon" href="/logo.ico" />
</head>

<body>
<!--顶部-->
<?php include("top.php");?> 
<!--顶部结束--->
<!--主体部分-->
<div class="down-main">
	<!--左侧部分-->
  <?php include("left.php");?> 
  <!--左侧部分结束-->
  <!--右侧部分-->
  <div class="right-product right-full">
  	<!--右侧内容部分-->
    <div class="container-fluid right-product-con">
    	<div class="mianbaoxie"><i class="glyphicon-folder-open glyphicon"></i>
    		<span>管理中心</span>&gt;数据汇总</div>
        <div class="container-con">
      		<!--表格-->
      		<div class="tableCon">
			<div class="tableCon-tit clear"><span class="mianbaoxie">数据汇总</span></div>
	      		<div class="tableCon-content">
				<table width="98%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC" class="wenzi">
  <form id="form1" name="form1" method="post" action="pwd_edit.php">
    <tr>
      <td width="16%" bgcolor="#F7F7F7"><div align="right"><font color="#333333">图片空间使用配额</font>： </div></td>
      <td width="84%" height="25" bgcolor="#F7F7F7"><div align="left"><?php echo diskTransform($maxhostsize);?></div></td>
    </tr>
    <tr>
      <td bgcolor="#F7F7F7"><div align="right"><font color="#333333">已使用</font>：</div></td>
	  <?php if($rowuser["thetype"]=="超级管理员"){$sqls="select sum(currenthostsize) as zs from ph_admin where thetype='管理员'";
$results=mysqli_query($conn,$sqls);
$rows= mysqli_fetch_array($results);}?>
      <td height="25" bgcolor="#F7F7F7"><div align="left"><div class="progress"><div class="progress-bar progress-bar-info" role="progressbar"
		 aria-valuenow="60" aria-valuemin="0" aria-valuemax="100"
		 style="width:<?php if($rowuser["thetype"]=="超级管理员"){echo (int)(($currenthostsize+$rows["zs"])/$maxhostsize*100);}else{echo (int)($currenthostsize/$maxhostsize*100);}?>%;">	
	</div>
</div><?php echo diskTransform($currenthostsize);?> <?php if($rowuser["thetype"]=="超级管理员"){echo "总使用量：".diskTransform($rows["zs"]+$currenthostsize);}?></div></td>
    </tr>
    <tr>
      <td bgcolor="#F7F7F7"><div align="right"><font color="#333333">剩余</font>：</div></td>
      <td height="25" bgcolor="#F7F7F7">
	<?php echo diskTransform($maxhostsize-$currenthostsize);?></td>
    </tr>
    
    <tr>
      <td bgcolor="#F7F7F7"><div align="right">产品总数：</div></td>
      <td height="25" bgcolor="#F7F7F7"><div align="left"><?php echo $rowcount[0];?></div></td>
    </tr>
  </form>
</table>
	      		</div>
	      	</div>
	      	<!--表格结束--->
      	</div>
      </div>
  </div>
	  <!--右侧内容部分结束-->
  </div>
  <!--右侧部分结束-->
</div>
<!--主体部分结束-->
<script src="/js/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="/js/mcommon.js"></script>
</body>
</html>
